﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.pp.stmtformatter.type.comm
{
	// Token: 0x02000213 RID: 531
	public class UpdateStmtFormatter : AbstractStmtFormatter
	{
		// Token: 0x06001244 RID: 4676 RVA: 0x00318763 File Offset: 0x00316963
		public virtual void addSetClauseProcessor(AbstractProcessor p)
		{
			if (this.setClauseProcessors == null)
			{
				this.setClauseProcessors = new List<AbstractProcessor>();
			}
			this.setClauseProcessors.Add(p);
		}

		// Token: 0x06001245 RID: 4677 RVA: 0x00318784 File Offset: 0x00316984
		public virtual void addWhereClauseProcessor(AbstractProcessor p)
		{
			if (this.whereClauseProcessors == null)
			{
				this.whereClauseProcessors = new List<AbstractProcessor>();
			}
			this.whereClauseProcessors.Add(p);
		}

		// Token: 0x06001246 RID: 4678 RVA: 0x003187A8 File Offset: 0x003169A8
		protected internal override void doFormat(TCustomSqlStatement stmtArg)
		{
			TUpdateSqlStatement tupdateSqlStatement = stmtArg as TUpdateSqlStatement;
			this.runProcessor<TUpdateSqlStatement>(this.SpecialProcessors, tupdateSqlStatement);
			if (tupdateSqlStatement.ResultColumnList != null && tupdateSqlStatement.ResultColumnList.size() > 0)
			{
				this.runProcessor<TResultColumnList>(this.setClauseProcessors, tupdateSqlStatement.ResultColumnList);
				for (int i = 0; i < tupdateSqlStatement.ResultColumnList.size(); i++)
				{
					TResultColumn resultColumn = tupdateSqlStatement.ResultColumnList.getResultColumn(i);
					if (resultColumn.Expr != null && resultColumn.Expr.RightOperand != null && resultColumn.Expr.RightOperand.SubQuery != null)
					{
						ExpressionProcessor.processParenthesesNodeInSubQuery(this.Option, resultColumn.Expr.RightOperand.SubQuery, resultColumn.Expr.RightOperand.SubQuery.startToken, resultColumn.Expr.RightOperand.SubQuery.endToken);
					}
				}
			}
			if (tupdateSqlStatement.WhereClause != null)
			{
				this.runProcessor<TExpression>(this.whereClauseProcessors, tupdateSqlStatement.WhereClause.Condition);
				this.runProcessor<TExpression>(this.ExpressionProcessors, tupdateSqlStatement.WhereClause.Condition);
			}
		}

		// Token: 0x040013F1 RID: 5105
		private IList<AbstractProcessor> setClauseProcessors;

		// Token: 0x040013F2 RID: 5106
		private IList<AbstractProcessor> whereClauseProcessors;
	}
}
